#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

class point{
	public:
	int x;
	int y;
	int z;
};
bool operator<(point a,point b){
	if(a.z<b.z)return true;
	return false;
}
double Length(point a,point b){
	return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2)+pow(a.z-b.z,2));
}

int main(void){
	int n=0;
	double ans=0;
	point temp;
	vector<point> data;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>temp.x>>temp.y>>temp.z;
		data.push_back(temp);
	}
	sort(data.begin(),data.end());
	n--;
	for(int i=0;i<n;i++){
		ans+=Length(data[i],data[i+1]);
	}
	printf("%.3f",ans);
	return 0;
}
